Imports System.IO       'For the handy Path.Stuff functions
Imports System.Xml
Imports System.Drawing
Imports System.Drawing.Imaging

Partial Class atomcontrols_controls_ImageLiblist
    Inherits System.Web.UI.UserControl

    Private _allowedFiles() As String = {".gif", ".jpg"}
    Private _maxSizeKb As Integer = 50
    Private _imageLibPath As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'The default path to the image library xml file.
        _imageLibPath = Server.MapPath("~/App_Data/imagelib.xml")

        'Setup the Xml data source.
        XmlImageLib.DataFile = _imageLibPath
        XmlImageLib.EnableViewState = False
        XmlImageLib.EnableCaching = False

    End Sub


    Private Function isExtValid(ByVal ext As String) As Boolean
        Dim isExtAllowed As Boolean = False

        'Find out if the actual file extension matches one of our allowed types.
        For Each ae As String In _allowedFiles
            If ae = ext Then
                isExtAllowed = True
                Exit For
            End If
        Next
        Return isExtAllowed
    End Function

    ''' <summary>
    ''' The full path to the image library xml.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property ImageLibPath() As String
        Get
            Return _imageLibPath
        End Get
        Set(ByVal value As String)
            _imageLibPath = value
        End Set
    End Property


    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

        ImageList.DataSource = XmlImageLib
        ImageList.DataBind()

    End Sub

End Class
